<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .finish {
            text-decoration: line-through;
            color: red;
        }

        li:hover {
            cursor: pointer;
        }
    </style>
</head>

<body>
    <input type="text" id="input" value="">
    <button id="add">add</button>
    <ul class="content">
        <li>red</li>
        <li>blue</li>
        <li>green</li>
        <li>yellow</li>
    </ul>


    <script>


        let add = document.getElementById('add');
        let input = document.getElementById('input');
        let content = document.getElementsByClassName('content')[0];
        let lis = content.children;
        add.onclick = function () {
            if (input.value) {
                content.innerHTML += `<li>${input.value}</li>`
                input.value = '';
                check()
            }

        }

        function check() {
            for (let item of lis) {
                item.onclick = function () {
                    item.classList.toggle('finish')
                }
            }
        }




    </script>

</body>

</html>